home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
keyb
/
keybuf21.zip
/
KEYBUF.DOC
< prev
Wrap
Text File
|
1994-01-20
|
9KB
|
190 lines
ARCHIVE NAME : VRKBUF21.ZIP
PROGRAM NAME : KeyBuf (c) 1992-1994
VERSION : 2.10
PROGRAM TYPE : Tool (BIOS patcher)
DISTRIBUTION : PUBLIC DOMAIN (with restrictions)
PURPOSE : Expands the keyboard buffer to 128 keystrokes
AUTHOR : Vincenzo ROMANO
ADDRESS : Via A.Omodeo, 3
I-56124 Pisa ITALY
E-MAIL : vromano@NYX.cs.du.edu
RELEASED : 20 Jan. 1994
REQUIREMENTS : AT-class BIOS, DOS 2.1+ (read below)
0 - DISCLAIM and LEGAL STUFF
.-----------------------------------------------.
| THIS PROGRAM IS ABSOLUTELY FREE OF ANY CHARGE |
| FOR NON-COMMERCIAL AND NON-PROFITABLE USES. |
| FOR COMMERCIAL OR PROFITABLE USES YOU HAVE TO |
| CONTACT THE AUTHOR BEFORE USING IT. |
| THE AUTHOR WILL NOT BE RESPONSIBLE IN ANY WAY |
| OF ANY KIND OF DAMAGE DUED TO THE USE OF THIS |
| PROGRAM. |
| YOU CAN RE-DISTRIBUTE THIS PROGRAM PROVIDED |
| THAT THIS DOCUMENTATION FILE IS DISTRIBUTED |
| ALONG WITH THE PROGRAM ITSELF. |
| IF YOU RE-DISTRIBUTE THIS PROGRAM YOU CANNOT |
| CHARGE IT FOR MORE THAN THE COST OF THE MEDIA |
| SUPPORT. |
| THE USE AND RE-DISTRIBUTION OF THIS PROGRAM |
| IMPLY THE AGREEMENT TO THE STATEMENTS ABOVE. |
`-----------------------------------------------'
1 - INTRODUCTION
Any PC has a memory buffer to keep the keystrokes not already
read.
Unluckyly this buffer is set to be only 16 keystrokes long:
this could not be a problem for some people while it does for
many others ( like me ).
Let's say that we want to run these programs while having a
coffee break:
CHKDSK /F C:
DEL C:\*.CHK
DEFRAG C:\ /QUIET
The time needed to accomplish this task can be very long,
especially because you have to wait for the CHKDSK to finish. A
keyboard buffer too short doesn't help you: you cannot type the
three command lines and then go away. This is only one example!
And then, what's the solution? It's easy to answer: write your
own keyboard buffer expander or use KeyBuf!
Now it's time to tell you something. When you type characters
ahead, you have to know what you're going to do: computers do
exactly what you asked them to. Nothing more, nothing less!
When you hit ^C ( Control-C ) or BREAK ( Control-Pause ) the
BIOS will erase any unread keystrokes from the buffer: this is a
BIOS feature, not a KeyBuf one.
2 - HOW DOES KeyBuf WORK?
.-----------------------------------------------.
| These are technical notes. You're required to |
| know some low level knowledges to fully |
| understand them ( offsets, segments, etc. ). |
`-----------------------------------------------'
The standard PC BIOSes ( Basic I/O System ) store a circular
buffer for the unread keystrokes (2 bytes each) in a memory area
called BVS ( BIOS Variables Segment ) located at 0040:0000h.
To manage this circular buffer the BIOS needs of four
pointers, namely:
head : the next place where the BIOS will put a new keystroke,
tail : the next place from where the BIOS gets a keystroke,
bot : the starting address of the buffer,
top : the upper limit of the buffer.
buffer for the unread keystrokes (2 bytes each) in a memory area
Anytime we ask the BIOS for a keystroke, the value pointed by
`tail' is read and the pointer advanced ( if we reach `top' the
BIOS wraps it to `bot' ).
Anytime we hit a key, the BIOS stores the new keystroke into
the two bytes pointed by `head' and advances the pointer ( if we
reach `top' ... ).
If `head' reaches `tail' we are running out of the buffer
space and will lost this keystroke and subsequent ones.
If `tail' reaches `head' we have emptied the buffer.
In XT-class BIOSes, the `bot' and `top' values are hard coded
into the ROM and we can't solve the problem ( unless we re-write
the BIOS keyboard manager ).
In AT-class BIOSes they are stored as real variables into the
BVS. So we'd need only to set some new values into those four
variables to set a brand new keyboard buffer.
But we're only starting the dances!
The four pointers are stored as OFFSETs: the SEGMENT is hard
coded to be the BVS. We cannot put the new buffer anywhere: it
is to be within the 64 Kb limit of the BVS, that is its `top' is
to be lower than 1040:0000h in memory.
I.e., if we want a 256 bytes buffer, it can be set in memory
as high as:
1040:0000h - 256 = 10400h - 100h = 10300h = 1030:0000h.
Usually, the PC memory is allocated as follows:
Segment | Lenght | Description
--------|--------|---------------
0000h | 1024 | Interrupts vector
0040h | 256 | BIOS Variables Segment
0050h | 512 | DOS System Variables {can vary in lenght}
0070h | ???? | BIOS extensions ( IO.SYS )
????h | ???? | DOS handlers ( MSDOG.SYS )
????h | ???? | DOS buffers, data and device drivers
????h | ???? | Resident portion of the shell (COMMAND.COM)
????h | ???? | TSRs and programs
Maybe that all the memory below the 1040:0000h limit is busy:
we cannot allocate a new keyboard buffer.
If we are running MS-DOG 5.0+ or are using some system tool,
we can move the last three `memory eaters' somewhere else ( the
HMA and the UMBs ) thus freeing our precious lower memory. This
is the best case to use KeyBuf!
Anytime we run a program after the boot procedure (CONFIG.SYS)
the DOS allocates two memory blocks for it: one for a copy of
the variables environment and one, just above the first, for the
program itself.
So, the lowest memory block we can use is the environment if
it's large enough, that is if it's 256 bytes long at least.
If the environment is too tight, KeyBuf tries to allocate some
other memory.
This should not be a problem today: lots of programs need some
environment variable to run and the users set environments
larger than 256 bytes!
KeyBuf allocates/deallocates memory by using the standard DOS
memory services ( services 48h and 49h of int21h ) as introduced
in the MS-DOG 2.1+ .
Now you can understand that KeyBuf is not a TSR but only a
BIOS patcher: KeyBuf doesn't steal CPU time!
For more details please read the source code.
3 - HOW TO USE KeyBuf
Usually you have only to put KeyBuf in some directory of your
hard disk and add a line in your AUTOEXEC.BAT file to call it as
high as possible. In other words you should run KeyBuf as early
as possible in your boot sequence.
To see if KeyBuf `really' got installed, try to run it once
again: KeyBuf will complain if run twice.
No installation procedure is needed.
If you're running some TSR that accesses the keyboard buffer
pointers (like the ones that automatically generate keystrokes
to force a "file save"), be sure to call KeyBuf BEFORE them.
I think you can assemble KeyBuf as a device driver too to put
it in the CONFIG.SYS by slightly modifying its sources.
I have never tried such a thing.
One more thing. If your `environment space' is less than 256
bytes long, maybe you'll get an error message telling you that
"all memory below 1030:0 is busy" even if your memory below 1030
is not all used.
If you like this program or use it, I'd like to receive a
postcard of your country or of your city. Please, feel free to
contact me for suggestions and bug reports.
4 - HISTORY
0.8 [9 Apr. 1992]
Used only by me and by my friends
1.0 [17 Oct. 1992]
Added comments to the sources. Interrupts get disabled.
2.0 [